package com.healthy.medical.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.medical.domain.PhysicalExamItems;
import com.healthy.medical.service.IPhysicalExamItemsService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 体检项目Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/PhysicalExamItems")
public class PhysicalExamItemsController extends BaseController
{
    @Autowired
    private IPhysicalExamItemsService physicalExamItemsService;

    /**
     * 查询体检项目列表
     */
    @RequiresPermissions("medical:PhysicalExamItems:list")
    @GetMapping("/list")
    public TableDataInfo list(PhysicalExamItems physicalExamItems)
    {
        startPage();
        List<PhysicalExamItems> list = physicalExamItemsService.selectPhysicalExamItemsList(physicalExamItems);
        return getDataTable(list);
    }

    /**
     * 导出体检项目列表
     */
    @RequiresPermissions("medical:PhysicalExamItems:export")
    @Log(title = "体检项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PhysicalExamItems physicalExamItems)
    {
        List<PhysicalExamItems> list = physicalExamItemsService.selectPhysicalExamItemsList(physicalExamItems);
        ExcelUtil<PhysicalExamItems> util = new ExcelUtil<PhysicalExamItems>(PhysicalExamItems.class);
        util.exportExcel(response, list, "体检项目数据");
    }

    /**
     * 获取体检项目详细信息
     */
    @RequiresPermissions("medical:PhysicalExamItems:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(physicalExamItemsService.selectPhysicalExamItemsById(id));
    }

    /**
     * 新增体检项目
     */
    @RequiresPermissions("medical:PhysicalExamItems:add")
    @Log(title = "体检项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PhysicalExamItems physicalExamItems)
    {
        return toAjax(physicalExamItemsService.insertPhysicalExamItems(physicalExamItems));
    }

    /**
     * 修改体检项目
     */
    @RequiresPermissions("medical:PhysicalExamItems:edit")
    @Log(title = "体检项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PhysicalExamItems physicalExamItems)
    {
        return toAjax(physicalExamItemsService.updatePhysicalExamItems(physicalExamItems));
    }

    /**
     * 删除体检项目
     */
    @RequiresPermissions("medical:PhysicalExamItems:remove")
    @Log(title = "体检项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(physicalExamItemsService.deletePhysicalExamItemsByIds(ids));
    }
}
